package com.myboot.demo.handler;

import com.myboot.demo.exception.SellerAuthorizeException;
import com.myboot.demo.exception.TestException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author: 韦溜溜
 * @Description:
 * @Date: Create in 20:21 2019/1/12
 */
@ControllerAdvice
public class SellerExceptionHandler {

    @ExceptionHandler(value = SellerAuthorizeException.class)
    public ModelAndView handlerSellerAuthorizeException(){
        return new ModelAndView("redirect:"+"https://www.baidu.com");
    }

    @ExceptionHandler(value = TestException.class)
    @ResponseStatus(value = HttpStatus.FORBIDDEN)  //改变异常返回给客户端的状态显示：404或者是其他状态
    public void handlerTest(){
    }

}
